//api统一管理
import requests from "./request";
import mockRequest from './mockRequest';

export const reqCategoryList = () => {
    return requests({
        url: '/product/getBaseCategoryList',
        method: 'get',
    });
};

export const reqBannerList = () => {
    return mockRequest({
        url: '/banner',
        method: 'get'
    });
};

export const reqFloorList = () => {
    return mockRequest({
        url: '/floor',
        method: 'get'
    });
};

export const reqSearchInfo = (params) => {
    return requests({
        url: '/list',
        method: 'post',
        data: params
    })
};

export const reqDetailInfo = (skuId) => {
    return requests({
        url: `/item/${skuId}`,
        method: 'get'
    })
};

//添加到购物车
export const reqGoodsCarInfo = (skuId, skuNum) => {
    return requests({
        url: `/cart/addToCart/${skuId}/${skuNum}`,
        method: 'post'
    })
};

//获取购物车列表
export const reqShopCartInfo = () => {
    return requests({
        url: '/cart/cartList',
        method: 'get'
    })
};

//获取验证码
export const reqPhoneCodeInfo = (phone) => requests({
    url: `/user/passport/sendCode/${phone}`,
    method: 'get'
});

//完成注册
export const reqRegisterOkInfo = (data) => requests({
    url: '/user/passport/register',
    data,
    method: 'post'
});

//用户登录
export const reqUserLoginInfo = (data) => requests({
    url: '/user/passport/login',
    data,
    method: 'post'
});

//获取用户信息
export const reqUserInfo = () => requests({
    url: '/user/passport/auth/getUserInfo',
    method: 'get'
});


//退出登录
export const reqUserLogoutInfo = () => requests({
    url: '/user/passport/logout',
    method: 'get'
});

//切换商品选中状态
export const reqischeckedInfo = (skuId, isChecked) => requests({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: 'get'
});

//删除某一商品
export const reqDeleteInfo = (skuId) => requests({
    url: `/cart/deleteCart/${skuId}`,
    method: 'delete'
});

//获取订单信息
export const reqTradeInfo = () => requests({
    url: '/order/auth/trade',
    method: 'get'
});

//提交订单
export const reqOrderOk = (tradeNo, data) => requests({
    url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
    method: 'post',
    data
});

//获取订单支付信息
export const reqPayInfo = (orderId) => requests({
    url: `/payment/weixin/createNative/${orderId}`,
    method: 'get'
});

//获取订单支付状态
export const reqOrderStatus = (orderId) => requests({
    url: `/payment/weixin/queryPayStatus/${orderId}`,
    method: 'get'
});

//获取我的订单信息
export const reqMyCenterInfo = (page, limit) => requests({
    url: `/order/auth/${page}/${limit}`,
    method: 'get'
})